{config_load file="global.conf" section="`$lang`"}
{config_load file="_ForecastItem.conf" section="`$lang`"}
{*-------------------------------------------------------------------------------------------------------------------------------------*}
{* setting global variables *}
{if !$forecast.active } {assign var="pips" value=`$forecast.close.pip`} {else} {assign var="pips" value=`$forecast.pip`}{/if}
{if 1==$forecast.side} {assign var="operation" value="SELL"} {else}{assign var="operation" value="BUY"}{/if}
{* /setting global variables *}
{*-------------------------------------------------------------------------------------*}
{* choose type *}
{*  0 or not set - forex forecasts *}
{*  1 - html email *}
{*  2 - text email *}
{*  3 - compact text email*}
{*  4 - html without image email *}
{if !$messagetype || 1==$messagetype || 4==$messagetype}
{*-------------------------------------------------------------------------------------------------------------------------------------*}
{* HTML header *}
{*-------------------------------------------------------------------------------------------------------------------------------------*}
{if  1==$messagetype || 4==$messagetype} {* fonts for emails *}
<div style="font-size:14px; font-family:Verdana, Arial, Helvetica, sans-serif; ">
{/if} {* / fonts for emails *}
{*-------------------------------------------------------------------------------------*}
{*style*}
{literal}
<style type="text/css">
        #spanActive_Normal {
            display:inline;
            color:black;
            background-color:white;
            white-space: nowrap;
        }

        #spanActive_Plus {
            display:inline;
            color: #76923e;
            background-color:white;
            white-space: nowrap;
        }

        #spanActive_Minus {
            display:inline;
            color:red;
            background-color:white;
            white-space: nowrap;
        }

        #spanNoActive_Normal {
            display:inline;
            color:gray;
            background-color:white;
            white-space: nowrap;
        }

        #spanNoActive_Plus {
            display:inline;
            color: #76923e;
            background-color:white;
            white-space: nowrap;
        }

        #spanNoActive_Minus {
            display:inline;
            color:red;
            background-color:white;
            white-space: nowrap;
        }
        </style>
{/literal}
{*/style*}
{*-------------------------------------------------------------------------------------*}
{* setting variables *}
{if $forecast.active }
    {assign var="styleNormal" value="spanActive_Normal"}
    {if $pips<0}
        {assign var="styleColored" value="spanActive_Minus"}
    {else}
        {assign var="styleColored" value="spanActive_Plus"}
    {/if}
{else}
    {assign var="styleNormal" value="spanNoActive_Normal"}
    {if $pips<0}
        {assign var="styleColored" value="spanNoActive_Minus"}
    {else}
        {assign var="styleColored" value="spanNoActive_Plus"}
    {/if}
{/if}

{assign var="fstr" value="%0.`$forecast.decimal`f"}
{* /setting variables *}
{*-------------------------------------------------------------------------------------*}
{*$forecast.id*}
<a name="{$rate.Symbol}" ></a>
{if $flagShowSystem}System: <b>{$forecast.system.name}</b><br>
Action: <b>{if 0==$trade_mode}Open{else}Close {$forecast.close.reason}{/if}</b> <br><br>{/if} {* Show system label and action *}
{* main table*}
<table border="0" >
    {*-------------------------------------------------------------------*}
    {if $forecast.color }{*&& 3==$forecast.color*}  {* exists  forecasts *}
    {*-------------------------------------------------------------------*}

<tr>
    <td>Position ID: </td>
    <td><b>{$forecast.system.shortname}{$forecast.id}</b></td>

    <td width="30px">&nbsp;</td>

    <td><span id="{$styleNormal}">Generation time:</span></td>
    <td><span id="{$styleNormal}"><b>{$forecast.begin.time_formated}</b></span></td>
    {*$forecast.begin.time|date_format:"%Y-%m-%d %I:%M %p GMT"*}
</tr>

<tr>
    <td colspan="2">
        <span id="{$styleColored}"><b>{$forecast.pair}</b></span>
        <span id="{$styleNormal}"><b>{$operation}&nbsp;[MARKET ORDER]</b></span>
    </td>

    <td width="30px">&nbsp;</td>

    <td colspan="2">
        <span id="{$styleNormal}">Lots:</span>
        <span id="{$styleNormal}"><b>{$forecast.size}</b></span>
    </td>
</tr>

<tr>
    <td><span id="{$styleNormal}">Entry:</span></td>
    <td><span id="{$styleNormal}"><b>{$forecast.begin.price|string_format:"`$fstr`" }</b></span></td>{*"%.4f"*}

    <td width="30px">&nbsp;</td>

    <td><span id="{$styleNormal}">Expiration time:</span></td>
    <td><span id="{$styleNormal}">{if !$forecast.flag.end.time}<b>{$forecast.end.time_formated}</b>{else}-{/if}</span></td>
    {*$forecast.end.time|date_format:"%Y-%m-%d %I:%M %p GMT"*}
</tr>

<tr>
    <td><span id="{$styleNormal}">Stop-Loss:</span></td>
    <td><span id="{$styleNormal}">{if $forecast.stop.price}<b>{$forecast.stop.price|string_format:"`$fstr`"|default:"-"}</b>{else}-{/if} {if $forecast.stop.pip}[{$forecast.stop.pip} pips]{/if}</span></td>

    <td width="30px">&nbsp;</td>

    <td><span id="{$styleNormal}">Take Profit:</span></td>
    <td><span id="{$styleNormal}">{if !$forecast.flag.end.price}<b>{$forecast.end.price|string_format:"`$fstr`"}</b> [{$forecast.end.pip} pips]{else}-{/if}</span></td>
</tr>

{* forecast is closed *}
{if !$forecast.active }
<tr>
    <td><span id="{$styleNormal}">Close time:</span></td>
    <td><span id="{$styleNormal}"><b>{$forecast.close.time_formated}{*$forecast.close.time|date_format:"%Y-%m-%d %I:%M %p GMT"*}</b></span></td>

    <td width="30px">&nbsp;</td>

    <td><span id="{$styleNormal}">Close Price:</span></td>
    <td><span id="{$styleNormal}">{if $forecast.close.price}<b>{$forecast.close.price|string_format:"`$fstr`"}</b> [{$forecast.close.pip} pips]{else}-{/if}</span></td>
</tr>
{/if}
{* /forecast is closed *}


<tr>
    <td>Status:  </td>
    <td><b>{if !$forecast.active }Closed trade {$forecast.close.reason}{else}Trading...{/if}</b></td>

    <td width="30px">&nbsp;</td>

    <td>{if !$forecast.active }NET P/L:{else}Floating P/L:{/if}</td>
    <td><b><span id="{$styleColored}">{$pips}</span> pips</b></td>
</tr>

    {*-------------------------------------------------------------------*}
    {/if} {* /exists  forecasts *}
    {*-------------------------------------------------------------------*}
{*-------------------------------------------------------------------*}
{if $flagShowRate }{* show rate*}
{assign var="fstr_rate" value="%0.`$rate.decimal`f"}
<tr>
    {if 1==$rate.Direction}
        {assign var=classstyle value="up"}
    {elseif  -1==$rate.Direction}
        {assign var=classstyle value="down"}
    {else}
        {assign var=classstyle value="none"}
    {/if}
    <td><a name="{$forecast.pair}"></a>Current rate: </td>
    <td colspan="3">
    <b>
        <span class="{$classstyle}">{$rate.Bid|string_format:"`$fstr_rate`"}</span>
        &nbsp;/&nbsp;
        <span class="{$classstyle}">{$rate.Ask|string_format:"`$fstr_rate`"}</span>
        </b>&nbsp;at&nbsp;<b>
        <span class="time">{$rate.RateTimeFormated}{*$rate.RateTime|date_format:"%I:%M %p GMT"*}</span>

        {if 1==$rate.Direction}
           <img width="12" height="12" src="{#images_dir#}/rates/arrow_up.png" />
        {elseif  -1==$rate.Direction}
           <img width="12" height="12" src="{#images_dir#}/rates/arrow_down.png" />
        {else}
           &nbsp;
        {/if}

</b>
    </td>
</tr>
{/if}{* / show rate*}
{*-------------------------------------------------------------------*}
</table>
{* /main table *}
{*-------------------------------------------------------------------*}
{if  1==$messagetype || 4==$messagetype} {* fonts for emails *}
</div>
{/if} {* / fonts for emails *}
{*-------------------------------------------------------------------------------------------------------------------------------------*}
{* /HTML header *}
{*-------------------------------------------------------------------------------------------------------------------------------------*}
{elseif  2==$messagetype}
{*-------------------------------------------------------------------------------------------------------------------------------------*}
{* TEXT header *}
{*-------------------------------------------------------------------------------------------------------------------------------------*}
{if $flagShowSystem} System: {$forecast.system.name} {/if} {* Show system label *}

{if $forecast.color }{*&& 3==$forecast.color*} {* exists  forecasts*}
{assign var="fstr" value="%0.`$forecast.decimal`f"}
Position ID: {$forecast.system.shortname}{$forecast.id}  Generation time:{$forecast.begin.time_formated}
{$forecast.pair} {$operation}&nbsp;[MARKET ORDER]  Lots: {$forecast.size}
Entry: {$forecast.begin.price|string_format:"`$fstr_rate`"}  Expiration time: {if !$forecast.flag.end.time} {$forecast.end.time_formated}{else}-{/if}
Stop-Loss:{if $forecast.stop.price}{$forecast.stop.price|string_format:"`$fstr_rate`"|default:"-"}{else}-{/if} {if $forecast.stop.pip}[{$forecast.stop.pip} pips]{/if} Take Profit:{if !$forecast.flag.end.price} {$forecast.end.price|string_format:"`$fstr_rate`"} [{$forecast.end.pip} pips]{else}-{/if}
Expiration time: {if !$forecast.flag.end.time} {$forecast.end.time_formated}{else}-{/if}
Status:{if !$forecast.active }Closed trade {$forecast.close.reason}{else}Trading{/if} {if !$forecast.active }NET P/L:{else}Floating P/L:{/if}{$pips} pips
{* forecast is closed *}
{if !$forecast.active }
    Close time: {$forecast.close.time_formated}  Close Price: {if $forecast.close.price} {$forecast.close.price|string_format:"`$fstr_rate`"} [{$forecast.close.pip} pips]{else}-{/if}
{/if}
{* /forecast is closed *}


{/if} {* /exists  forecasts *}
{*-------------------------------------------------------------------------------------------------------------------------------------*}
{* /TEXT header *}
{*-------------------------------------------------------------------------------------------------------------------------------------*}
{elseif  3==$messagetype}
{*-------------------------------------------------------------------------------------------------------------------------------------*}
{* Compact text header *}
{*-------------------------------------------------------------------------------------------------------------------------------------*}
{assign var="fstr" value="%0.`$forecast.decimal`f"}
{if 1==$forecast.side} {assign var="operation" value="SELL"}{else}{assign var="operation" value="BUY"}{/if}
{if 0==$trade_mode} {assign var="mode" value="OPEN"}{else}{assign var="mode" value="CLOSE"}{/if}
{if $forecast.color }{$forecast.system.name}:
Time: {if !$forecast.active }{$forecast.close.time_formated}{*$forecast.close.time|date_format:"%Y-%m-%d %I:%M %p GMT"*}{else}{$forecast.begin.time_formated}{*$forecast.begin.time|date_format:"%Y-%m-%d %I:%M %p GMT"*}{/if}

{$mode} {if !$forecast.active }{$forecast.close.reason}{/if} {$forecast.pair} {$operation} MARKET ORDER @ {if !$forecast.active }{$forecast.close.price|string_format:"`$fstr`"}{else}{$forecast.begin.price|string_format:"`$fstr`" }{/if}

{if !$forecast.active }
NET P/L: {$pips} pips
{else}
TP: {$forecast.end.price|string_format:"`$fstr`"}
SL: {$forecast.stop.price|string_format:"`$fstr`"|default:"-"}{/if}

ID: {$forecast.system.shortname}{$forecast.id}{/if}
{*-------------------------------------------------------------------------------------------------------------------------------------*}
{* /Compact text header *}
{*-------------------------------------------------------------------------------------------------------------------------------------*}


{elseif  33==$messagetype}
{*-------------------------------------------------------------------------------------------------------------------------------------*}
{* Compact text header *}
{*-------------------------------------------------------------------------------------------------------------------------------------*}
{if $forecast.color }{*&& 3==$forecast.color*} {* exists  forecasts*}
{$forecast.pair}
Start rate: {$forecast.begin.price} at {$forecast.begin.time_formated}{*$forecast.begin.time|date_format:"%Y-%m-%d %I:%M %p GMT"*}
Forecast rate: {$forecast.end.price|default:"-"} at {$forecast.end.time_formated}{*$forecast.end.time|date_format:"%Y-%m-%d %I:%M %p GMT"*}
Stop-Loss rate: {$forecast.stop.price}
{/if} {* /exists  forecasts *}
{*-------------------------------------------------------------------------------------------------------------------------------------*}
{* /Compact text header *}
{*-------------------------------------------------------------------------------------------------------------------------------------*}
{/if}
{* /choose type *}
